<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@	page import="org.corp.agi.web.constant.WebConstant"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="cd" uri="/WEB-INF/tld/commondisplay-tag.tld"%>
<%@ include file="/ncos/templates/templateConstants.jsp"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${ initParam.appName }</title>
<link href="${ requestScope.cssBase }/style.css" rel="stylesheet" type="text/css">
<script language="javascript" src="${requestScope.jsBase }/imageutils.js"></script>
<!-- yav validation -->
<link rel="stylesheet" href="${requestScope.agiCssBase}/yav-style.css " type="text/css" />
<script type="text/javascript" src="${requestScope.agiJSBase}/yav.js"></script>
<script type="text/javascript" src="${requestScope.agiJSBase}/yav-config.js"></script>		
<!-- jQuery -->
<script type="text/javascript" src="${requestScope.jsBase}/jquery-1.7.2.min.js"></script>		
<%@include file="/ncos/templates/commonDWR.jspf"%>
<script type="text/javascript">
var $j = jQuery.noConflict();
</script>	
</head>

<body class="body">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td>
    		<table width="780"	border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td colspan="4"><img src="${ imageBase }/namecard_bg_01.png" width="780" height="29" alt=""></td>
				</tr>
      			<tr>
        			<td width="29" rowspan="3" background="${ imageBase }/namecard_bg_02.png"><img src="${ imageBase }/namecard_bg_02.png" width="29" height="1" alt=""></td>
					<td width="199" height="54" bgcolor="#000000"><img src="${ imageBase }/logo.png" width="191" height="54"></td>
					<td width="523" bgcolor="#000000">
				        <!-- Menu -->
				       	<jsp:include page="/ncos/templates/topmenu.jsp"></jsp:include>
      				</td>
      				<td width="29" rowspan="3" background="${ imageBase }/namecard_bg_04.png"><img src="${ imageBase }/namecard_bg_04.png" width="29" height="1" alt=""></td>
      			</tr>
      			<tr>
        			<td height="15" colspan="2" valign="top" bgcolor="#000000"></td>
      			</tr>
      			<tr>
        			<td colspan="2" valign="top" bgcolor="#000000">
						<table width="722" border="0" cellpadding="0" cellspacing="0" class="bg3">
							<tr>
     							<td width="50%" valign="top">
     								<table width="300" height="40" border="0" align="left" cellpadding="0" cellspacing="0">
       									<tr>
         									<td class="font02">เข้าสู่ระบบ</td>
       									</tr>
     								</table>
     							</td>
     							<td width="50%">
     							<%-- Login --%>
     								<c:if test="${empty sessionScope[request.SESSION_USERBEAN_KEY]}">
     								<form id="loginForm" action="login-login.htm" method="POST">
     								<table width="250" height="144" border="0" align="left" cellpadding="0" cellspacing="0">
							       		<tr>
                  							<td height="34" colspan="2">&nbsp;</td>
							       		</tr>
       									<tr>
         									<td width="77" height="30" class="font07">ชื่อผู้ใช้งาน</td>
         									<td width="173"><label for="username"></label><input name="username" type="text" class="form_user_pass" id="username"><br/><span id="errorsDiv_username"></span></td>
       									</tr>
       									<tr>
								       		<td height="30" class="font07">รหัสผ่าน</td>
								         	<td height="30"><label for="password"></label><input name="password" type="password" class="form_user_pass" id="password"><br/><span id="errorsDiv_password"></span></td>
								      	</tr>
								      	<tr>
								        	<td height="30">&nbsp;</td>
								        	<td height="30"><input type="button" value="เข้าสู่ระบบ" onclick="doLoginForm()">&nbsp;
								        	<input type="button" value="Clear" onclick="clearForm();"></td>
								      	</tr>
								      	<tr>
							         		<td height="20">&nbsp;</td>
											<td class="font06" style="color: red;">
												<div id="alert" class="alert" style="display: none;"></div>
											</td>
										</tr>
								       	<tr>
								         	<td height="20" class="font07"></td>
								         	<td height="20" class="font07"></td>
								         	<!-- 
								         	<td class="font06"><a href="<s:property value="#request.appBase"/>/accesscontrol/changePassword-init.htm">Change password</a></td>
								          	-->
								       	</tr>
                						<tr>
                  							<td height="30" class="font07">&nbsp;</td>
                  							<td class="font06">&nbsp;</td>
                						</tr>
							     	</table>
							     	</form>
     								</c:if>
     							</td>
   							</tr>
          					<tr>
            					<td colspan="2">
            						<table width="600" height="200" bgcolor="#CCCCCC" border="0" align="center" cellpadding="20" cellspacing="0">
					              		<tr>
					                		<td class="font06_2">แสดงรายละเอียดที่อยู่ในตำแหน่งพื้นที่เขตของคุณ,<strong> กรุณาล็อคอินเข้าสู่ระบบ *</strong><br><hr></td>
					              		</tr>
              							<tr>
                							<td valign="top"><span class="font07_2">
                								บริษัท ไปรษณีย์ไทย จำกัด</span><br>
                  								<span class="font07_3">111 หมู่ 3 ถนนแจ้งวัฒนะ แขวงทุ่งสองห้อง เขตหลักสี่ กรุงเทพฯ 10210-0299<br>
                    							โทรศัพท์ : 0-2831-3864, 0-2575-1439 โทรสาร : 0-2574-4211<br>
                    							e-mail : </span><span class="font07">somchai.th@thailandpost.co.th</span>
                    						</td>
              							</tr>
            						</table>
            					</td>
          					</tr>
          					<tr>
            					<td valign="top">&nbsp;</td>
            					<td valign="top">&nbsp;</td>
          					</tr>
 						</table>
        			</td>
      			</tr>
      			<tr>
        			<td height="29" colspan="4" background="${ imageBase }/namecard_bg_06.png" class="font00">Copyright © 2012 Print@Thailandpost All rights reserved.</td>
      			</tr>
    		</table>
    	</td>
	</tr>
</table>
<script language="javascript">
function doLoginForm()
{
	var rules=new Array();
    rules[0] = 'username:User Name|required';
    rules[1] = 'password:Password|required';

    //if (yav.performCheck('loginForm', rules, 'inline')){
   	if (yav.performCheck('loginForm', rules, 'classic')){
    	$j("#loginForm").submit();
    }
	
}
function clearForm()
{
	$j('#username').val('');
	$j('#password').val('');
	$j('#roleOption').val('');
	$j('#role').val($j('#roleOption').val());
	$j('#alert').fadeOut(500);
	$j('.innerError').html('').removeClass('innerError');
}
$j("input[name='password']").keypress(function(event){
		if(event.which==13){
			doLoginForm();
		}
	});
	
$j(document).ready(function(event){
	//test();
});
function test(){
	if($j.browser.msie){
		$j('#username').val('approver1');
		$j('#password').val('password');
	}else{
		$j('#username').val('user1');
		$j('#password').val('password');
	}
	$j('#loginForm').submit();
}
function showResponse(responseText, statusText, isErrorPage) {
	//error/warning/info
	eval( "var o = " + responseText + "" );
	var status = o.status;
	var content = "";
	if (o.messageList != null) {
		for (var i=0; i<o.messageList.length; i++) {
			//content += "<strong>" + o.messageList[i].messageCode + "</strong>"+" : "+o.messageList[i].messageText+"<br/>";
			content += o.messageList[i].messageText+"<br/>";
		}
	}
	
	$j("#alert").html(content).show();
	$j("#username").focus();
}
showResponse('{'
		+'"status":"${sessionScope.SESSION_STATUS_KEY}",'
		+'"messageList":${cd:escJS(sessionScope.SESSION_MESSAGE_KEY)}}',
		''); 
</script>
</body>
</html>
 